package com.wyiot.pet.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wyiot.pet.model.entity.UserMessageDO;
import com.wyiot.core.security.UserContext;
import com.wyiot.pet.service.MessageService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 消息管理控制层
 *
 * @author yly
 * @since 2022年04月11日
 */
@RestController
public class MessageController{
    @Resource
    MessageService messageService;

    /**
     * 查看消息列表
     *
     */
    @GetMapping("/message/list")
    public Page<UserMessageDO> queryMessageByUserId(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum
            , @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam("type") Integer type){
        return messageService.queryMessageList(pageNum, pageSize, type, UserContext.getUserCode());
    }
}
